# -*- coding: utf-8 -*-

#   This file is part of deckbuilder.
#
#    DeckBuilder is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 2 of the License, or
#    (at your option) any later version.
#
#    DeckBuilder is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with deckbuilder; if not, write to the Free Software
#    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

import os, sys
import xmlhandler

# Dictionary contenente i settings
# Esempio:
# >>> print settings.settings['Language']
# >>> English
#settings = dict()

def LoadSettings(): # Metodo per il caricamento dei settings
    settings = dict()
    xmldoc = xmlhandler.LoadXml(os.path.join(sys.path[0], 'settings.xml'))
    # Apro il file xml contenente i settings
    if xmldoc == False: # Nel caso non trova il file la funzione ritorna False
        #TODO: Implementare creazione file settings.xml di default
        return
    for node in xmldoc.firstChild.childNodes:
            settings[node.getAttribute('name')] = node.getAttribute('value')
            # Inserisco nel dizionario i settings leggendo i nodi del xml, es. settings['Language'] = 'English'
    return settings